
import { defineStore } from 'pinia'
import { ref } from 'vue'
import request from "../../plugins/request.ts";

// 用户模块 token setToken removeToken

export const useUserStore = defineStore(
    'currentLoginUser',
    () => {
        const currentLoginUserInfo = ref({})
        const setCurrentLoginUser = (user: any) => {
            currentLoginUserInfo.value = user
        }
        const getCurrentLoginUser = async () => {
            const result = await request.get('/user/current')
            if (result.data.data) {
                currentLoginUserInfo.value = result.data.data
            }
        }
        return {
            currentLoginUserInfo,
            setCurrentLoginUser,
            getCurrentLoginUser
        }
    },
    {
        persist: {
            key: 'partner-login-user-info'
        }
    },
)
